package pokerTests;

import junit.framework.TestCase;
import poker.*;

public class HumanTest extends TestCase {

	public void testInputScramble() throws Exception {
		int i[] = { 4, 2, 1, 0 };
		int result[] = new int[4];

		Human.readInput(result, "      4 2 1 ");
		assertSame(result[0], i[0]);
		assertSame(result[1], i[1]);
		assertSame(result[2], i[2]);
		assertSame(result[3], i[3]);
	}

	public void testInputInvalidChar() throws Exception {
		int i[] = new int[4];

		try {
			Human.readInput(i, " 2a");
			fail();
		} catch (Exception e) {}

		try {
			Human.readInput(i, "a");
			fail();
		} catch (Exception e) {}

		try {
			Human.readInput(i, "    a");
			fail();
		} catch (Exception e) {}

		try {
			Human.readInput(i, "7");
			fail();
		} catch (Exception e) {}

		try {
			Human.readInput(i, "    -1");
			fail();
		} catch (Exception e) {}

		try {
			Human.readInput(i, "    39");
			fail();
		} catch (Exception e) {}
	}

	public void testSameNumbers() throws Exception {
		int i[] = new int[4];

		try {
			Human.readInput(i, "11");
			fail();
		} catch (Exception e) {}
	}

	public void testNullString() throws Exception {
		int i[] = new int[4];

		try {
			Human.readInput(i, null);
			fail();
		} catch (Exception e) {
			assertTrue(e.getMessage(), e.getMessage() == "Pusta linijka!");
		}
	}

	public void testPass() throws Exception {
		int i[] = new int[4];

		Human.readInput(i, "    0");
		assertTrue(i[0] == 0);
	}
}
